package com.android.test.util;

import android.app.Activity;
import android.content.SharedPreferences;

public class SharedPreferencesUtil {
	
	private static final String PREFS_NAME = "setting";
	
	private SharedPreferencesUtil(){}
	
	public static void putInt(Activity ac, String key, int value){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putInt(key, value)
		    .commit();
	}
	
	public static void putFloat(Activity ac, String key, float value){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putFloat(key, value)
		    .commit();

	}
	
	public static void putLong(Activity ac, String key, long value){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putLong(key, value)
		    .commit();

	}
	
	public static void putBoolean(Activity ac, String key, boolean value){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putBoolean(key, value)
		    .commit();

	}
	
	public static void putString(Activity ac, String key, String value){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		settings.edit()
		    .putString(key, value)
		    .commit();

	}
	
	public static int getInt(Activity ac, String key, int defValue){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		return settings.getInt(key, defValue);
	}
	

	public static float getFolat(Activity ac, String key, Float defValue){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		return settings.getFloat(key, defValue);
	}

	public static long getLong(Activity ac, String key, long defValue){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		return settings.getLong(key, defValue);	
	}

	public static boolean getBoolean(Activity ac, String key, boolean defValue){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		return settings.getBoolean(key, defValue);
	}

	public static String getString(Activity ac, String key, String defValue){
		SharedPreferences settings = ac.getSharedPreferences(PREFS_NAME, 0);
		return settings.getString(key, defValue);
	}

}
